﻿using AutoMapper;
using HuaweiCloud.Dotnet.Samples.Common;
using HuaweiCloud.Dotnet.Samples.Common.Cache.Extension;
using HuaweiCloud.Dotnet.Samples.ESports.Main.Dtos;
using HuaweiCloud.Dotnet.Samples.ESports.Main.Entities;
using HuaweiCloud.Dotnet.Samples.ESports.Main.Specification;
using Microsoft.Extensions.Caching.Distributed;
using Volo.Abp.Guids;

namespace HuaweiCloud.Dotnet.Samples.ESports.Main.Service
{
    public class CommunityEventsService : CrudApplicationServiceBase<CommunityEvents
        , CreateCommunityEventsDto
        , UpdateCommunityEventsDto
        , CommunityEventsDto>
        , ICommunityEventsService 
    {
        private readonly IGuidGenerator _idGenerator;
        public CommunityEventsService(IRepository<CommunityEvents> repository
            , IMapper mapper
            , IGuidGenerator idGenerator
            ) : base(repository, mapper)
        {
            _idGenerator = idGenerator;

        }

        public override Task AddAsync(CreateCommunityEventsDto t, CancellationToken token = default)
        {
            t.Id = _idGenerator.Create();
            return base.AddAsync(t, token);
        }
    }
}
